//
//  LGComposePhotosView.m
//  微博
//
//  Created by MS on 15-12-24.
//  Copyright (c) 2015年 MS. All rights reserved.
//

#import "LGComposePhotosView.h"

@implementation LGComposePhotosView

-(void)setImage:(UIImage *)image
{
    _image = image;
    UIImageView * imagV = [[UIImageView alloc] initWithImage:image];
    
    [self addSubview:imagV];
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    int cols = 3;
    
    CGFloat wh = (self.width -(cols-1)*LGPhotoMargin)/cols;
    
    for (int i =0; i<self.subviews.count; i++) {
        UIImageView * imgV = self.subviews[i];
        
        int col = i%cols;
        int rol = i/cols;
        CGFloat x = (wh + LGPhotoMargin)*col;
        CGFloat y = (wh + LGPhotoMargin)*rol;
        imgV.frame = CGRectMake(x, y, wh, wh);
    }
    
}

@end
